# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=bv-sized
pkgname=haskell-bv-sized
pkgver=1.0.5
pkgrel=22
pkgdesc="A bitvector datatype that is parameterized by the vector width"
url="https://github.com/GaloisInc/bv-sized"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-bitwise' 'haskell-panic' 'haskell-parameterized-utils'
         'haskell-random' 'haskell-th-lift')
makedepends=('ghc' 'uusi' 'haskell-hedgehog' 'haskell-monadrandom' 'haskell-tasty'
             'haskell-tasty-hedgehog')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('a06fed039d1ae56caaea5aaa8443c11665de6b3c9e6bcc62f6864b0c2c01887a96cf46e951c2566fa50cc486eaf31f56688a34d6747f59e1fe9f808bbe6e36d3')

prepare() {
    cd $_hkgname-$pkgver
    gen-setup
}

build() {
    cd $_hkgname-$pkgver    
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
